package com.example.myapplication;


/**
 * @author: rongfeng
 * @date: 2020/7/13
 * @description
 */
public class CommonUtils {
    //防连续点击
    private static long lastClickTime;

    public static boolean isFastDoubleClick() {
        long time = System.currentTimeMillis();
        long timeD = time - lastClickTime;
        if (0 < timeD && timeD < 800) {
            return true;
        }
        lastClickTime = time;
        return false;
    }

    /**
     * 获取堆栈日志保存
     * @param ex
     */
    public static void saveStackTraceLog(Throwable ex) {
        try {
            StackTraceElement[] stackElements = ex.getStackTrace();//通过Throwable获得堆栈信息
            if (stackElements != null && stackElements.length > 0) {
                for (int i = 0; i < stackElements.length; i++) {
                    String log = stackElements[i].getClassName() + "/t" +
                            stackElements[i].getFileName() + "/t" +
                            stackElements[i].getLineNumber() + "/t" +
                            stackElements[i].getMethodName();
                }
            }
        } catch (Exception e) {

        }
    }
}
